1. Field
Embodiments relate to the separation of user interface logic from user interface presentation by using a protocol.
2. Background
User interface (UI) frameworks may separate the code that controls the UI presentation from the code that controls the logical behavior. The UI presentation may include graphics, animations, layouts etc., and the code for logical behavior may manage logical states, when and what data should be presented to a user, and reactions to user actions.
The separation of the code that controls the UI presentation from the code that controls the logical behavior is desirable since the development of the two types of code may require different development skills. Furthermore each type of code may be changed without any change being made to the other. Coupling of the UI presentation code with the code for the logical behavior may make maintenance harder and more complex. For that reason coding patterns such as Model View Controller (MVC) and Model View ViewModel (MVMM) may be used to separate the code that controls the UI presentation from the code that controls the logical behavior.
MVC is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that the information is presented to or accepted from the user. The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface. The model directly manages the data, logic and rules of the application. A view can be any output representation of information, such as a chart or a diagram. The third part, the controller, accepts input and converts it to commands for the model or view. In addition to dividing the application into three kinds of components, the MVC design defines the interactions between them.
MVVM is an architectural pattern for software development. MVVM abstracts a view's state and behavior. As in the MVC, the view is the user interface. The view model is an abstraction of the view that exposes public properties and commands. Instead of the controller of the MVC pattern, MVVM has a binder. In the view model, this binder mediates communication between the view and the data binder. The binder frees the developer from being obliged to write logic to synchronize the view model and view.
Presentation logic is the application code that defines the logical behavior and structure of the application in a way that is independent of any specific user interface implementation. When implementing the separated presentation pattern, the presentation logic components may include a presenter, a presentation model, and ViewModel components. FIG. 1 shows a prior art framework 100 that shows interactions between a presentation logic code 102 and a UI logic code 104, via notifications 106, data binding 108, and commands 110 between a view 112 and a ViewModel 114, where the view 112 corresponds to a user interface 116.
Such UI frameworks may allow separation of component logic from its presentation. There are numerous UI frameworks today that are targeted towards separating the logic and the presentation. Some frameworks run both the presentation side and the presentation logic in the same process like in desktop graphical user interface (GUI) frameworks, such as, JavaFX*, Swing, Windows Presentation Foundation (WPF). Certain UI frameworks may provide means for separation between the presentation and its logic for each component (i.e. table, form etc.) using data-binding. Similarly, in the world of Web UI (e.g., JavaScript*/HTML5), there are numerous JavaScript frameworks that provide a similar separation for each component, such as, AngularJS, Backbone.js and Ember.js. *JavaFX, JavaScript are trademarks or registered trademarks of Oracle America, Inc.